--[[

	field可用参数:
	
	[所在位置(必须数字)] = { 
		field = "entry", 			-- 必填,field用于区分是字段或布局,并用于生成SQL的字段名依据.除此之外下面的属性均是选填,等号后是默认值.
		orientation = false, 		-- 布局,默认 false(垂直). 可改为 true(水平)
		type = 1,					-- 字段类型,
		isFilter = false,			-- 是否为可用于筛选器的字段
		hiddenColumn = false,		-- 是否在搜索页面的表格中隐藏该列(建议隐藏部分用处不大的字段)
		hiddenLabel = false,		-- 是否隐藏Label
		name = "物品id"				-- 该字段显示的名字
		textColor = "#ffffffff",	-- 字段显示的文字的颜色
		tooltip = "工具提示",		-- 鼠标悬停输入框时弹出的提示文字
		borderColor = "#567d00"		-- 边框颜色,不填写则不显示边框
		width = 100,				-- 框体宽度
		height = 100,				-- 框体高度
		
		
		--跳转,如果编辑器的某一个字段关联其他表格的字段的话,可用设置以下参数进行设置
		--这里以item_template.PageText对应page_text.ID作为示例
		linkTable = "page_text",	-- 表示关联字段所在表格
		linkTargetFidle = "ID",		-- 表示关联的目标字段名
		linkDatabase = "world",		-- 如果目标不在同一个数据库中,则需要设置所在的数据库,可不填,不填则表示在同一个数据库中的不同表格
		
		
		--展示额外数据,如果想要在一个编辑器中展示其他表格的数据的话,可以设置以下参数
		--这里以展示page_text.text进行示例,其实类似跳转,只不过跳转是使用原有字段进行跳转,这里是新增一个可跳转的展示字段
		--首先设置目标表格
		linkDatabase = "world",		-- 如果目标不在同一个数据库中,则需要设置所在的数据库,可不填,不填则表示在同一个数据库中的不同表格
		linkTable = "page_text",	-- 表示关联字段所在表格
		--设置它是根据什么字段进行关联并获取数据 (item_template.PageText对应page_text.ID)
		linkFidle = "PageText",		-- 原表的字段
		linkTargetFidle = "ID", 	-- 目标表的字段
		--设置想要展示PageText中的text字段,
		field = "Text",
		
	}

]]--

Editors = Editors or {}

-- 法术布局
-- 这里偷下懒,用个循环生成table
local spell = { orientation = true,	borderColor = "#567d00"}
local spellFields = {}
table.insert(spellFields,"spellid_")
table.insert(spellFields,"spelltrigger_")
table.insert(spellFields,"spellcharges_")
table.insert(spellFields,"spellppmRate_")
table.insert(spellFields,"spellcooldown_")
table.insert(spellFields,"spellcategory_")
table.insert(spellFields,"spellcategorycooldown_")
local spell_zhcn = {"法术ID","法术触发类型","释放次数","ppmRate","冷却时间","法术分类","类型冷却"}

for i = 1,5 do
	spell[i] = spell[i] or {}
	spell[i].orientation = true
	for k,v in pairs(spellFields) do
		spell[i][k] = spell[i][k] or {}
		spell[i][k].field = v..i
		if (i ~= 1) then
			spell[i][k].hiddenLabel = true
		else
			spell[i][k].name = spell_zhcn[k]
		end
	end
end
-- 法术布局 end

--各种需求布局
local Required = 
{
	borderColor = "#CCCCCC",
	{
		orientation = true,
		{
			{field = "RequiredLevel", name = "需要等级"},
			{field = "requiredspell", name = "需要法术"},
		},
		
		{
			{field = "requiredhonorrank", name = "需要荣誉"},
			{field = "RequiredCityRank", name = "需要城市等级"},
		},
	},
	
	{
		orientation = true,
		borderColor = "#CCCCCC",
		{field = "RequiredSkill", name = "需要技能"},
		{field = "RequiredSkillRank", name = "需要技能等级"},
	},
	
	{
		borderColor = "#CCCCCC",
		orientation = true,
		{field = "RequiredReputationFaction", name = "声望类型要求"},
		{field = "RequiredReputationRank", name = "需要声望等级"},
	},
}
--需求布局 end


--抗性组
local Res = 
{
	borderColor = "#CCCCCC",
	{
		orientation = true,
		{field = "holy_res", name = "神圣抗性"},
		{field = "fire_res", name = "火焰抗性"},
		{field = "nature_res", name = "自然抗性"},
	},
	{
		orientation = true,
		{field = "frost_res", name = "冰霜抗性"},
		{field = "shadow_res", name = "暗影抗性"},
		{field = "arcane_res", name = "奥术抗性"},
	}
}
--抗性组布局 end

--属性组布局
local Stat = {
	borderColor = "#CCCCCC",
	{field = "StatsCount", name = "属性数量",orientation = true},
	
	{
		orientation = true,
		borderColor = "#cccccc",
		{
			{field = "stat_type1", name = "属性类型", },
			{field = "stat_type2", hiddenLabel = true, },
			{field = "stat_type3", hiddenLabel = true, }, 
			{field = "stat_type4", hiddenLabel = true, }, 
			{field = "stat_type5", hiddenLabel = true, }, 
			{field = "stat_type6", hiddenLabel = true, },  
			{field = "stat_type7", hiddenLabel = true, }, 
			{field = "stat_type8", hiddenLabel = true, }, 
			{field = "stat_type9", hiddenLabel = true, }, 
			{field = "stat_type10", hiddenLabel = true, },
		},
		{
			{field = "stat_value1", name = "属性值"},
			{field = "stat_value2", hiddenLabel = true},
			{field = "stat_value3", hiddenLabel = true},
			{field = "stat_value4", hiddenLabel = true},
			{field = "stat_value5", hiddenLabel = true},
			{field = "stat_value6", hiddenLabel = true},
			{field = "stat_value7", hiddenLabel = true},
			{field = "stat_value8", hiddenLabel = true},
			{field = "stat_value9", hiddenLabel = true},
			{field = "stat_value10", hiddenLabel = true},
		},
	},
	{field = "ScalingStatDistribution", name = "缩放属性分配",orientation = true},
	{field = "ScalingStatValue", name = "缩放属性基准值",orientation = true},
}
--属性组布局完成

--装备相关的属性
local equip = 
{
	borderColor = "#CCCCCC",
	{
		orientation = true,
		{field = "armor", name = "护甲"},
		{field = "ArmorDamageModifier", name = "额外护甲"},
		{field = "block", name = "格挡值"},
	},
	{
		orientation = true,
		{field = "delay", name = "攻击速度"},
		{field = "ammo_type", name = "弹药"},
		{field = "RangedModRange", name = "攻击范围"},
	},
	{
		orientation = true,
		{field = "itemset", name = "套装属性"},
		{field = "InventoryType", name = "武装备位置"},
		{field = "sheath", name = "武器摆放位置"},
		
	},
	{field = "MaxDurability", name = "最大耐久"},
	{
		orientation = true,
		{field = "dmg_type1", name = "伤害类型"},
		{field = "dmg_min1", name = "最小伤害"},
		{field = "dmg_max1", name = "最大伤害"},
	},
	{
		orientation = true,
		{field = "dmg_type2", name = "伤害类型", hiddenLabel = true},
		{field = "dmg_min2", name = "最小伤害", hiddenLabel = true},
		{field = "dmg_max2", name = "最大伤害", hiddenLabel = true},
	},
}
--装备相关的属性布局完成

--插槽和宝石
local gem = 
{
	borderColor = "#CCCCCC",
	{
		borderColor = "#CCCCCC",
		{
			orientation = true,
			{field = "socketColor_1", name = "插槽颜色"},
			{field = "socketContent_1", name = "插槽开关"},
		},
		
		{
			orientation = true,
			{field = "socketColor_2", hiddenLabel = true},
			{field = "socketContent_2", hiddenLabel = true },
		},
		
		{
			orientation = true,
			{field = "socketColor_3", hiddenLabel = true },
			{field = "socketContent_3", hiddenLabel = true},
		},
	},
	{
		{field = "socketBonus", name = "插槽奖励", orientation = true,},
		{field = "GemProperties", name = "宝石属性", orientation = true,},
	}
}


local item_template = {
	Type = "mysql",				--必填,编辑器类型,以后可能会添加dbc的支持
	Database = "world",			--表格所在数据库
	Table = "item_template",	--表格的名字
	Name = "item_template",		--编辑器名字,用于显示在编辑器左上显示,唯一,同时也用于注册对象
	Fields = {		--字段设置,说明在上方
		[130] = {field = "Text",name = "书本文字(测试跨表数据展示)", isFilter = true, linkDatabase = "fd_world", linkTable = "page_text", linkFidle="PageText", linkTargetFidle = "ID"},		
		{
			{
				orientation = true,
				{field = "entry", name = "物品id",isFilter = true},
				{field = "name", name = "物品名称",isFilter = true},
				{field = "class", name = "物品类型",isFilter = true},
				{field = "subclass", name = "物品子类型",isFilter = true},
			},
			
			{
				orientation = true,
				{field = "ItemLevel", name = "物品等级",isFilter = true},
				{field = "Quality", name = "品质",isFilter = true},
				{field = "AllowableRace", name = "种族要求", type = "Flag16"},
				{field = "AllowableClass", name = "职业要求", type = "Flag16" },
			},
			
			{
				orientation = true,
				{field = "displayid", name = "图标和模型"},
				{field = "bonding", name = "绑定类型"},
				{field = "RandomProperty", name = "随机属性"},
				{field = "RandomSuffix", name = "随机前缀"},
			},
			
			{
				orientation = true,
				{field = "minMoneyLoot", name = "最小金钱掉落"},
				{field = "maxMoneyLoot", name = "最大金钱掉落"},
				{field = "BuyPrice", name = "物品购买价钱"},
				{field = "SellPrice", name = "物品出售价钱"},
			},
			
			{
				orientation = true,
				{field = "BuyCount", name = "物品购买数量"},
				{field = "maxcount", name = "最大持有数"},
				{field = "stackable", name = "叠堆数"},
				{field = "ContainerSlots", name = "背包容量"},
			},
			
			{
				orientation = true,
				{field = "PageText", name = "页面文字",linkTable = "page_text", linkTargetFidle = "ID"},
				{field = "LanguageID", name = "语言id"},
				{field = "PageMaterial", name = "页面材质"},
				{field = "Material", name = "材质"},
			},
			
			{
				orientation = true,
				{field = "DisenchantID", name = "分解id"},
				{field = "HolidayId", name = "节日id"},
				{field = "lockid", name = "开锁id"},
				{field = "startquest", name = "开始任务id"},
			},
			
			{
				orientation = true,
				{field = "BagFamily", name = "背包类别"},
				{field = "TotemCategory", name = "图腾分类"},
				{field = "FoodType", name = "食物类别"},
				{field = "RequiredDisenchantSkill", name = "分解所需等级"},
			},
			
			{
				orientation = true,
				{field = "Flags", name = "物品标记", type = "Flag", flags = {}},
				{field = "FlagsExtra", name = "物品标记扩展"},
				{field = "flagsCustom", name = "物品标记自定义"},
				{field = "SoundOverrideSubclass", name = "SoundOverrideSubclass"},
			},
		},
		
		{
			Stat,--属性组
			{
				orientation = true,
				{field = "area", name = "区域"},
				{field = "Map", name = "地图"},
			},
		},
		
		{
			equip,
			Res,--抗性组
		},
		
		{
			Required,--需求组
			gem,
		},
		
		spell,--法术组,

		{
			{
			orientation = true,
			{field = "duration", name = "维持时间"},
			{field = "ItemLimitCategory", name = "物品装备数量限制"},
			{field = "ScriptName", name = "脚本名"},
			{field = "VerifiedBuild", name = "验证Build"},
			},
			{field = "description", name = "物品描述", isFilter=true},
		},
	
	}
}

table.insert(Editors, item_template)
